package com.pacifico.telebusca.web.listener;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;

public class AutenticacionListenerSuccess implements AuthenticationSuccessHandler {

	public void onAuthenticationSuccess(HttpServletRequest arg0,
			HttpServletResponse arg1, Authentication arg2) throws IOException,
			ServletException {
		// TODO Auto-generated method stub
		UserDetails userDetails = (UserDetails) arg2.getPrincipal();
		System.out.println("AutenticacionListenerSuccess " + userDetails.getUsername());		
		arg1.setStatus(HttpServletResponse.SC_OK);
		arg1.sendRedirect(arg0.getContextPath()+"/menu.jsp");
	}

}
